/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package business;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 *
 * @author duongna
 */
public class Status {
    private int writerId;
    private Account writerAcc;
    private String content;
    private Date date;

    public int getWriterId() {
        return writerId;
    }

    public void setWriterId(int writerId) {
        this.writerId = writerId;
    }

    public Account getWriterAcc() {
        return writerAcc;
    }

    public void setWriterAcc(Account writerAcc) {
        this.writerAcc = writerAcc;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the amount of time 
     * since the status is posted
     */
    public long getTimeAgo() {
        long timeAgo = (new Date()).getTime() - date.getTime();

        // convert to hour
        timeAgo = timeAgo/(1000*60);
        return timeAgo;
    }
    
    /**
     * set basic info for status from result set
     */
    public void setBasicInfo(ResultSet resultSet) throws SQLException {
        setWriterId(resultSet.getInt("writerId"));
        setContent(resultSet.getString("content"));
        setDate(resultSet.getTimestamp("date"));
    }
}
